package com.yyh1;

public class Snake extends Guaiwu{
    public Snake(String name, int shengmingzhi, int gongjili) {
        super(name, shengmingzhi, gongjili);
    }
    //行为
    //移动
    @Override
    public void move(){
        System.out.println("我是"+name+"，我走s型路线");
    }
    //补血
    public void buXue(){
        if (shengmingzhi<10){
            shengmingzhi+=20;
            System.out.println(name+"生命值低于10，自动补血20点");
        }
    }

    @Override
    public void attack() {
        buXue();//攻击前自动检查补血
        super.attack();
    }
}
